#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
查看fund_info_detail表前10条记录
"""

import os
import sys
import django  # type: ignore

# 设置Django环境
current_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, current_dir)
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'wealth_backend.settings')
django.setup()

from data_service.models import FundInfoDetail

def main():
    """查看fund_info_detail表前10条记录"""
    print("=== fund_info_detail表前10条记录详细信息 ===")
    
    # 获取总记录数
    total_count = FundInfoDetail.objects.count()
    print(f"\n总记录数: {total_count}")
    
    # 获取前10条记录
    records = FundInfoDetail.objects.all()[:10]
    
    for i, detail in enumerate(records, 1):
        print(f"\n{'='*60}")
        print(f"第 {i} 条记录")
        print(f"{'='*60}")
        print(f"基金代码: {detail.fund_code}")
        print(f"基金名称: {detail.fund_name}")
        print(f"基金全称: {detail.fund_full_name or '无'}")
        print(f"成立时间: {detail.establishment_date or '无'}")
        print(f"最新规模: {detail.latest_scale or '无'}")
        print(f"基金公司: {detail.fund_company or '无'}")
        print(f"基金经理: {detail.fund_manager or '无'}")
        print(f"托管银行: {detail.custodian_bank or '无'}")
        print(f"基金类型: {detail.fund_type or '无'}")
        print(f"评级机构: {detail.rating_agency or '无'}")
        print(f"基金评级: {detail.fund_rating or '无'}")
        print(f"创建时间: {detail.created_at}")
        print(f"更新时间: {detail.updated_at}")
        
        # 显示投资策略和投资目标的前100个字符
        if detail.investment_strategy:
            strategy_preview = detail.investment_strategy[:100] + "..." if len(detail.investment_strategy) > 100 else detail.investment_strategy
            print(f"投资策略: {strategy_preview}")
        else:
            print(f"投资策略: 无")
            
        if detail.investment_objective:
            objective_preview = detail.investment_objective[:100] + "..." if len(detail.investment_objective) > 100 else detail.investment_objective
            print(f"投资目标: {objective_preview}")
        else:
            print(f"投资目标: 无")
            
        if detail.performance_benchmark:
            benchmark_preview = detail.performance_benchmark[:100] + "..." if len(detail.performance_benchmark) > 100 else detail.performance_benchmark
            print(f"业绩比较基准: {benchmark_preview}")
        else:
            print(f"业绩比较基准: 无")
    
    print(f"\n{'='*60}")
    print("查询完成")

if __name__ == '__main__':
    main()